#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline int read(){
	int x=0;bool f=0;char ch=getchar();
	while(ch<'0'||ch>'9')f^=(ch=='-'),ch=getchar();
	while('0'<=ch&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
bool st;
const int Maxn=2e5+5;
int n,mod;
int f[450][Maxn];
inline void init(int N){
	f[0][0]=1;
	for(int i=1;i*i<=N;i++){
		for(int j=0;j<i;j++)f[i][j]=f[i-1][j];
		for(int j=0;i+j<=N;j++)f[i][i+j]=(f[i-1][i+j]+f[i][j])%mod;
	}
}
inline void solve(){
	n=read();int ans=0;
	for(int i=1;i*i<=n;i++)if((n-i*i)%2==0)ans=(ans+f[i][(n-i*i)/2])%mod;
	printf("%d\n",ans);
}
bool en;
signed main(){cerr<<(&st-&en)/1024.0/1024.0<<'\n';
	freopen("moon.in","r",stdin);
	freopen("moon.out","w",stdout);
	int T=read();mod=read();
	init(2e5);
	while(T--)solve();
	return 0;
}
/*
5 998244353
9
11
20
25
60


3 991145149
36
2995
199808

*/
